//
//  HeaderEntryCell.m
//  MobileShoppingMall
//
//  Created by 冯传昌 on 2021/4/22.
//  Copyright © 2021 冯传昌. All rights reserved.
//

#import "HeaderEntryCell.h"

#define ItemWidth ((ScreenWidth-20)/5-10)

@interface HeaderEntryCell()

@property (nonatomic,strong) UIImageView *iconImgV;

@property (nonatomic,strong) UILabel *titleLB;

@end


@implementation HeaderEntryCell

- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self initUI];
    }
    return self;
}

#pragma mark - setter
- (void)setModel:(MainPageHeaderModel *)model{
    _model = model;
    [self.iconImgV sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:LoadImage(@"首页_手机充值")];
    
    self.titleLB.text = model.name;
}

#pragma mark - UI
-(void)initUI{
    [self addSubview:self.iconImgV];
    [self addSubview:self.titleLB];
}

#pragma mark - lazy
- (UIImageView *)iconImgV{
    if (!_iconImgV) {
        _iconImgV = [[UIImageView alloc] initWithFrame:CGRectMake(ItemWidth/2-16, 0, 32, 32)];
    }
    return _iconImgV;
}
- (UILabel *)titleLB{
    if (!_titleLB) {
        _titleLB = [[UILabel alloc] initWithFrame:CGRectMake(5, self.iconImgV.bottom+9, ItemWidth-10, 15)];
        _titleLB.font = FontSet(11);
        _titleLB.textAlignment = NSTextAlignmentCenter;
        _titleLB.textColor = RGB(85, 85, 85);
    }
    return _titleLB;
}

@end
